home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-12-12 | 3.0 KB | 116 lines |
- /*
- * Copyright(C) 1996 Sony Corporation. All rights reserved.
- */
-
- import vrml.*;
- import vrml.field.*;
- import vrml.node.*;
- import java.util.*;
- import vs.*;
-
- public class touch extends Script{
- /* Node */
- //SFNode TouchNode;
-
- /* EventOut */
- SFVec3f TouchViewpointPosition;
- SFTime Floor2ndAudioClipStartTime;
- SFTime Floor2ndAudioClipStopTime;
- SFColor Floor2ndMaterialColor;
-
- float ViewPos[] = new float[3];
-
- static int R = 0;
- static int G = 1;
- static int B = 2;
-
- static int X = 0;
- static int Y = 1;
- static int Z = 2;
- static int DEGREE = 3;
-
-
- public void initialize() {
- /* Node */
- //TouchNode = (SFNode) getField( "TouchNode" );
-
- /* EventOut */
- TouchViewpointPosition = (SFVec3f) getEventOut( "TouchViewpointPosition" );
- Floor2ndAudioClipStartTime = (SFTime) getEventOut( "Floor2ndAudioClipStartTime" );
- Floor2ndAudioClipStopTime = (SFTime) getEventOut( "Floor2ndAudioClipStopTime" );
- Floor2ndMaterialColor = (SFColor) getEventOut( "Floor2ndMaterialColor" );
- }
-
- public void processEvent(Event e) {
- String name = e.getName () ;
-
- if(name.equals("TouchProximitySensorPosition_changed")) {TouchProximitySensorPosition_changed(e);}
- if(name.equals("TouchBoxTouchSensorIsActive")) {TouchBoxTouchSensorIsActive(e);}
- if(name.equals("TouchConeTouchSensorIsActive")) {TouchConeTouchSensorIsActive(e);}
- if(name.equals("Floor2ndProximitySensorIsActive")) {Floor2ndProximitySensorIsActive(e);}
- }
-
- public void TouchProximitySensorPosition_changed(Event e) {
- ConstSFVec3f pos = (ConstSFVec3f)e.getValue();
-
- ViewPos[X] = pos.getX();
- ViewPos[Y] = pos.getY();
- ViewPos[Z] = pos.getZ();
- }
-
- public void TouchTouchSensorIsActive(Event e) {
- ConstSFBool mouse_down = (ConstSFBool)e.getValue();
- double time = e.getTimeStamp();
-
- if (mouse_down.getValue()) return; /* mouseDown */
-
- //TouchStart( time );
- }
-
- public void TouchBoxTouchSensorIsActive(Event e) {
- ConstSFBool mouse_down = (ConstSFBool)e.getValue();
- float pos[] = new float[3];
-
- if (mouse_down.getValue()) return; /* mouseDown */
-
- pos = ViewPos;
- pos[Z] += 5.0f;
- TouchViewpointPosition.setValue(pos);
- }
-
- public void TouchConeTouchSensorIsActive(Event e) {
- ConstSFBool mouse_down = (ConstSFBool)e.getValue();
- float pos[] = new float[3];
-
- if (mouse_down.getValue()) return; /* mouseDown */
-
- pos = ViewPos;
- pos[Y] += 5.0f;
- TouchViewpointPosition.setValue(pos);
- }
-
- public void Floor2ndProximitySensorIsActive(Event e) {
- ConstSFBool proximity = (ConstSFBool)e.getValue();
- double time = e.getTimeStamp();
- float col[] = new float[3];
-
- if (proximity.getValue()) {
- Floor2ndAudioClipStartTime.setValue(time);
- Floor2ndAudioClipStopTime.setValue(-1);
- col[R] = 255.0f;
- col[G] = 0.0f;
- col[B] = 0.0f;
- }{
- Floor2ndAudioClipStopTime.setValue(time);
- col[R] = 0.0f;
- col[G] = 255.0f;
- col[B] = 0.0f;
- }
- Floor2ndMaterialColor.setValue(col);
-
- }
-
-
- }
-